package com.ac.scum.log.web.model.ftp.mapper;

import com.ac.scum.log.bean.ServerFTPLogLock;
import com.ac.scum.log.web.model.dashboard.DashboardDateItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ServerFTPLogLockMapper extends BaseMapper<ServerFTPLogLock> {

    @Select("select count(*) from server_ftp_file_log_lock where server_id = #{serverId} and server_time>#{startTime} and server_time<#{endTime} and success_flag = true and system_lock_flag = #{lockFlag}")
    Integer countSystemLockByDateAndIsSysLockFlag(@Param("serverId") Long serverId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("lockFlag") Boolean lockFlag);

    @Select("select count(*) as count,player_steam_id as data from server_ftp_file_log_lock where server_id = #{serverId} and server_time>#{startTime} and server_time<#{endTime} and success_flag = true and system_lock_flag = false group by player_steam_id order by count desc limit 10")
    @Results({
            @Result(property = "count", column = "count", javaType = Integer.class),
            @Result(property = "data", column = "data", javaType = Long.class),
    })
    List<DashboardDateItem<Long>> yesterdayEveryOpenPlayers(@Param("serverId") Long serverId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
}
